import { request, ResponseError, ResponseSuccess } from "../utils/request";
/**用户api命名空间 */
export namespace UserApi {
  /**登录 */
  export function login(
    code: string
  ): Promise<ResponseSuccess<{ token: string }> | ResponseError> {
    return request({
      url: "/auth/login",
      method: "POST",
      data: {
        code,
      },
    });
  }

  /**注册 */
  export function signup(
    avatarFileName: string,
    avatarUrl: string,
    nickname: string,
    code: string
  ): Promise<ResponseSuccess<{ token: string }> | ResponseError> {
    return request({
      url: "/auth/signup",
      method: "POST",
      data: {
        avatarFileName,
        avatarUrl,
        nickname,
        code,
      },
    });
  }
}
